Skip to content

chore: adopt faststream 0.7.1 TestBroker typing fix#43

Merged
lesnik512 merged 3 commits into
mainfrom
chore/faststream-0.7.1-testbroker-typing
Jun 4, 2026
Merged

chore: adopt faststream 0.7.1 TestBroker typing fix#43
lesnik512 merged 3 commits into
mainfrom
chore/faststream-0.7.1-testbroker-typing

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Bump faststream floor to >=0.7.1,<0.8 to pull in fix(testing): type TestBroker context result via __init__ overloads ag2ai/faststream#2903, which makes TestBroker generic over a second EnterType TypeVar (default Any) and threads it through __aenter__.
  • Bind EnterType = OutboxBroker on TestOutboxBroker so the entered context is typed as a single OutboxBroker (mirrors faststream-redis-timers PR test: T1/T2/T3 fetch parity, multi-worker drain, lease-lost subclass refactor #27).
  • Update get_broker_registry's return annotation to the new two-param TestBroker[Any, Any] shape so it matches upstream's try_it_out._get_broker_registry signature.
  • Add a regression test in tests/test_fake.py that pins the single-broker contract through any future upstream typing refactor.
  • Document the two pre-existing # ty: ignore directives (invalid-type-arguments on the class declaration, invalid-return-type on the registry return) in CLAUDE.md's ignore table. git blame proved they predate 0.7.1 and mask the BrokerUsecase config-invariance issue (same root cause as patch_broker_calls), not the upstream union-return-type bug the spec originally claimed; 0.7.1 does not obsolete them.

Test Plan

  • just install resolves faststream==0.7.1
  • just lint clean (ruff, format, ty check)
  • just test — 392 passed, 100% coverage (--cov-fail-under=100 gate satisfied)
  • New test_test_broker_aenter_returns_single_outbox_broker passes

🤖 Generated with Claude Code

lesnik512 and others added 3 commits June 4, 2026 12:51
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ag2ai/faststream#2903 makes TestBroker generic over a second EnterType
TypeVar (default Any) and threads it through __aenter__. Bind
EnterType = OutboxBroker in our TestOutboxBroker so the entered context
is typed as a single OutboxBroker rather than OutboxBroker | list[OutboxBroker].
Update the ASGI registry hook annotation to the new two-param shape and
bump the faststream floor to >=0.7.1.

Both pre-existing ty suppressions stay: git blame shows the class-line
# ty: ignore[invalid-type-arguments] on TestOutboxBroker predates 0.7.1
and masks a separate issue (BrokerUsecase invariance on its config-type
param, the same root cause already documented for patch_broker_calls).
The # ty: ignore[invalid-return-type] on get_broker_registry's dict
literal is the same generic-invariance story applied to the dict key
side — empirically still flagged on 0.7.1 even with the two-param
TestBroker annotation. The spec's claim that 0.7.1 would obsolete either
suppression was incorrect; ignore-table justifications in CLAUDE.md
updated accordingly.

Adds a regression test guarding the single-broker contract through
future upstream changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 self-assigned this Jun 4, 2026
@lesnik512 lesnik512 merged commit 22de000 into main Jun 4, 2026
3 checks passed
@lesnik512 lesnik512 deleted the chore/faststream-0.7.1-testbroker-typing branch June 4, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant